package com.xunk.system.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @ProjectName: xunk
 * @Package: com.xunk.system.vo
 * @ClassName: HomeBillInfo
 * @Author: dongxiaoxin
 * @Description: 账单信息
 * @Date: 2021/5/17 16:32
 * @Version: 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class HomeBillInfo implements Serializable {

    /**
     *  时间单位
     */
    private String date;

    /**
     *  业主姓名
     */
    private String name;
    /**
     *  电梯费用
     */
    private Map<String,String> eleBill = new HashMap<>();
    /**
     *  住宅费用
     */
    private Map<String,String> homeBill = new HashMap<>();
    /**
     *  汇总
     */
    private String total;

    public HomeBillInfo(String date,String name, BigDecimal eleBill, BigDecimal homeBill) {
        this.date = date;
        this.name = name;
        this.eleBill.put(BillType.ELE_BIll,eleBill == null ? "0" : eleBill.setScale(1,BigDecimal.ROUND_DOWN).toString());
        this.homeBill.put(BillType.HOME_BIll,homeBill == null ? "0" : homeBill.setScale(1,BigDecimal.ROUND_DOWN).toString());
        this.total = new BigDecimal(this.eleBill.get(BillType.ELE_BIll)).add(new BigDecimal(this.homeBill.get(BillType.HOME_BIll))).toString();
    }

    public HomeBillInfo(String name, BigDecimal eleBill, BigDecimal homeBill) {
        this.name = name;
        this.eleBill.put(BillType.ELE_BIll,eleBill == null ? "0" : eleBill.setScale(1,BigDecimal.ROUND_DOWN).abs().toString());
        this.homeBill.put(BillType.HOME_BIll,homeBill == null ? "0" : homeBill.setScale(1,BigDecimal.ROUND_DOWN).abs().toString());
        this.total = new BigDecimal(this.eleBill.get(BillType.ELE_BIll)).add(new BigDecimal(this.homeBill.get(BillType.HOME_BIll))).setScale(1,BigDecimal.ROUND_DOWN).toString();
    }

    interface BillType{

        String ELE_BIll = "电梯运行费";

        String HOME_BIll = "物业管理费-住宅";
    }
}
